
<?php
{
 	function binary_search($a, $first, $last, $key) {
        $lo = $first; 
        $hi = $last - 1; 
        while ($lo <= $hi) {
            $mid = (int)(($hi - $lo) / 2) + $lo;
            if (strcmp($a[$mid],$key)<0) {
                $lo = $mid + 1;
            } elseif (strcmp($a[$mid],$key)>0) {
                $hi = $mid - 1;
            } else {
                return $mid;
            }
        }
        return ($lo + 1);
    };
    
 $File = "nomi.txt"; 
 $lines = file($File);
 $idx = binary_search($lines, 0, sizeof($lines), $_GET['nome']);
  if ($idx<sizeof($lines))
 	echo "OK";
 else 
 	echo "NO";
}


  ?>
 